home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / cli / bb2cli.lha / BBgoesCLI / ExeBB.asm < prev    next >
Encoding:
Assembly Source File  |  1992-09-02  |  4.4 KB  |  196 lines

  1.  
  2. **********************************************************
  3. *          ExeBB v1.1                22.12.1994          *
  4. **********************************************************
  5. * copyright (c) 1994 by Jens Tröger, all rights reserved *
  6. *                    this is FREEWARE                    *
  7. **********************************************************
  8. *        written using HiSoft`s DevPac 3.04              *
  9. * greets fly to Oliver Reiff, "PackMAN" Falk Zühlsdorff  *
  10. * "Janosh" Jan Stötzer, Jan van den Baard,...            *
  11. **********************************************************
  12. * (non)sense: this will read the Bootblock from a given  *
  13. * floppy-drive and execute it                            *
  14. * works with KS1.2 and better                            *
  15. * USAGE: ExeBB <unit>                                    *
  16. **********************************************************
  17.  
  18.     opt    o+,p+ 
  19.  
  20.     move.l    a0,a5 
  21.  
  22. ; ----- alloc memory for bootblock and several structures 
  23.  
  24. alloc_mem    move.l    4.w,a6 
  25.     move.l    #1024+88+1,d0    ; Bootblock + Port/IO... 
  26.     move.l    #$10001,d1 
  27.     jsr    -198(a6)        ; _LVOAllocMem 
  28.     move.l    d0,a4        ; a4: PTR to mem
  29.      beq    exit 
  30.  
  31. ; -----  open dos.library
  32.  
  33. open_dos    lea    dosname(pc),a1 
  34.     moveq    #33,d0 
  35.     jsr    -552(a6)        ; _LVOOpenLibrary 
  36.     move.l    d0,d6        ; d6: DOSBase
  37.     beq    free_mem 
  38.  
  39. ; -----  get unit 
  40.  
  41. read_unit    cmp.b    #"d",(a5)+ 
  42.     bne    usage 
  43.     cmp.b    #"f",(a5)+ 
  44.     bne    usage 
  45.     moveq    #0,d0 
  46.     move.b    (a5)+,d0 
  47.     sub.b    #48,d0 
  48.     cmp.b    #4,d0 
  49.     bge    usage
  50.     cmp.b    #0,d0
  51.     blt    usage
  52.     move.l    d0,d2         ; d2: Unit 
  53.     cmp.b    #":",(a5)+ 
  54.     bne    usage
  55.  
  56. ; -----  add MessagePort to system
  57.  
  58. add_port    sub.l    a1,a1 
  59.     jsr    -294(a6)        ; _LVOFindTask 
  60.     move.l    d0,1024+16(a4) 
  61.     lea    1024(a4),a1
  62.     jsr    -354(a6)        ; _LVOAddPort 
  63.  
  64. ; -----  open trackdisk.device 
  65.  
  66. open_track    lea    trackname(pc),a0 
  67.     lea    1024+32(a4),a1    ; a1: DiskIO-Struc 
  68.     move.l    d2,d0 
  69.     moveq    #0,d1 
  70.     jsr    -444(a6)        ; _LVOOpenDevice 
  71.     tst.l    d0 
  72.     bne    err_nodev        ; FATAL !!!!!
  73.  
  74. ; -----  read bootblock 
  75.  
  76. read_bb    lea    1024+46(a4),a0    ; a0: RepPort 
  77.     lea           1024(a4),a1    ; a1: ReplyPort-Struc 
  78.     move.l    a1,(a0) 
  79.     lea    1024+32(a4),a1    ; a1: DiskIO-Struc 
  80.     move.w    #2,28(a1) 
  81.     move.l    #1024,36(a1) 
  82.     move.l    a4,40(a1) 
  83.     move.l    #0,44(a1) 
  84.     jsr    -456(a6)        ; _LVODoIO 
  85.     move.l    d0,d2
  86.     move    #9,28(a1) 
  87.     move.l    #0,36(a1) 
  88.     jsr    -456(a6)        ; _LVODoIO 
  89.     tst.l    d2
  90.     bne    err_nodoio
  91.  
  92. ; -----  ask before executing the bootcode
  93.  
  94. ask    move.l    d6,a6
  95.     lea    ask_text(pc),a2
  96.     moveq    #ask_text_end-ask_text,d3
  97.     bsr    write_msg
  98.     jsr    -54(a6)        ; _LVOInput
  99.     move.l    d0,d1
  100.     lea    1024+88(a4),a0
  101.     move.l    a0,d2
  102.     moveq    #1,d3
  103.     jsr    -42(a6)
  104.     move.l    4.w,a6        ; _LVORead
  105.     lea    1024+88(a4),a0
  106.     cmp.b    #"Y",(a0)
  107.     bne.s    close_dev
  108.  
  109. ; -----  execute code
  110.  
  111. execute_bb    movem.l    d0-d7/a0-a6,-(sp)
  112.     lea    1024+32(a4),a1    ; a1: io-struc of trackdisk
  113.     jsr    $0c(a4)        ; BB_BootCode
  114.     movem.l    (sp)+,d0-d7/a0-a6
  115.  
  116. ; -----  close trackdisk.device 
  117.  
  118. close_dev    lea     1024+32(a4),a1    ; a1: DiskIO-Struc 
  119.     jsr    -450(a6)        ; _LVOCloseDevice 
  120.  
  121. ; -----  remove port 
  122.  
  123. rem_port    lea    1024(a4),a1    ; a1: ReplyPort 
  124.     jsr    -360(a6)        ; _LVORemPort 
  125.  
  126. ; -----  close dos.library
  127.  
  128. close_dos    move.l    4.w,a6 
  129.     move.l    d6,a1 
  130.     jsr    -414(a6)        ; _LVOCloseLibrary 
  131.  
  132. ; -----  free allocated memory 
  133.  
  134. free_mem    move.l    a4,a1 
  135.     move.l    #1024+88+1,d0 
  136.     jsr    -210(a6)        ; _LVOFreeMem 
  137.  
  138. ; -----  returncode: 0 
  139.  
  140. exit    moveq    #0,d0 
  141.     rts 
  142.  
  143. ; -----  several messages
  144.  
  145. usage    lea    usage_text(pc),a2 
  146.     move.l    #usage_text_end-usage_text,d3 
  147.     bsr.s    write_msg 
  148.     bra    close_dos 
  149.  
  150. err_nodev    lea    err1_text(pc),a2 
  151.     moveq    #38,d3 
  152.     bsr.s    write_msg
  153.     move.l    4.w,a6
  154.     lea    1024(a4),a1    ; a1: ReplyPort 
  155.     jsr    -360(a6)        ; _LVORemPort 
  156.     bra.s    close_dos
  157.  
  158. err_nodoio    lea    err2_text(pc),a2 
  159.     moveq    #44,d3 
  160.     bsr.s    write_msg
  161.     move.l    4.w,a6
  162.     lea     1024+32(a4),a1    ; a1: DiskIO-Struc 
  163.     jsr    -450(a6)        ; _LVOCloseDevice 
  164.      lea    1024(a4),a1    ; a1: ReplyPort 
  165.     jsr    -360(a6)        ; _LVORemPort 
  166.     bra.s    close_dos
  167.  
  168. ; -----  write text to stdout
  169.  
  170. write_msg    move.l    d6,a6 
  171.     jsr    -60(a6)        ; _LVOOutput 
  172.     move.l    d0,d1 
  173.     move.l    a2,d2 
  174.     jmp    -48(a6)        ; _LVOWrite 
  175.  
  176. ; -----  names, texts
  177.  
  178. dosname    dc.b    "dos.library",0 
  179.     even 
  180. trackname    dc.b    "trackdisk.device",0 
  181.     even 
  182. err1_text    dc.b    "FATAL ERROR opening trackdisk.device.",10 
  183.     even 
  184. err2_text    dc.b    "Error reading Bootblock. No disk inserted ?",10 
  185.     even
  186. ask_text    dc.b    "Are you shure to execute the bootcode ?? This may"
  187.     dc.b    " cause a system crash !",10
  188.     dc.b    "Enter [Y] to execute, any other to cancel: "
  189. ask_text_end 
  190. usage_text    dc.b    10,$9b,"1mExeBB v1.1",$9b,"0m 1994 by Jens Tröger",10 
  191.     dc.b    "USAGE: ExeBB <unit>",10 
  192.     dc.b    "Where <unit> is one of your mounted floppies (df0:) ",10,10
  193. usage_text_end 
  194.  
  195.     end 
  196.